package com.atguigu.springcloud.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author Tu
 * @date 2023/3/26 16:06
 */
@Configuration
public class ApplicationContextConfig {

    /**
     * 容器注入 restTemplate
     * 注意这里要添加 @LoadBalanced注解，否则会报错找不到主机
     *
     * @return
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

}
